<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商城登录</title>
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="__STATIC__/css/pear.css"/>
    <link rel="stylesheet" href="__STATIC__/css/login.css"/>
</head>
<!-- 代 码 结 构 -->
<body background="__STATIC__/images/background2.svg" style="background-size: cover;">
<form class="layui-form" action="javascript:void(0);">
    <div class="layui-form-item">
        <img class="logo" src="__STATIC__/images/logo.png"/>
        <div class="title">爱笑的老茶</div>
        <div class="desc">
            欢 迎 来 到 老 茶 商 城 后 台 管 理
        </div>
    </div>
    <div class="layui-form-item">
        <input type="text" name="mobile" placeholder="手机号 : root " hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input type="password" name="password" placeholder="密 码 : root " hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input type="text" name="verify_code" placeholder="验证码 : " hover class="code layui-input layui-input-inline"/>
        <img src="{:captcha_src()}" id="verify_img" class="codeImage" onclick="refreshVerify()"/>
    </div>
    <div class="layui-form-item">
        <button type="button" class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
            登 入
        </button>
    </div>
</form>
<div style="text-align: center;padding-top: 10em">
    <a href="https://beian.miit.gov.cn">京ICP备2021022758号-1</a>
</div>
<!-- 资 源 引 入 -->
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__STATIC__/js/pear.js"></script>
<script src="__STATIC__/js/jquery.min.js"></script>
<script>
    $(function () {
        layui.use('form', function () {
            var form = layui.form;
            //监听提交
            form.on('submit(login)', function (data) {
                $.post("{:url('login')}", data.field, function (res) {
                    if (res.code == 0) {
                        layer.msg('登录成功', {icon: 6});
                        window.location.href = "{:url('index/index')}";
                    } else {
                        console.log(res)
                        // refreshVerify();
                        layer.msg(res.message, {icon: 2});
                    }
                }, 'json');
                return false;
            })
        })
    })

    function refreshVerify() {
        var random = Math.random();
        $('#verify_img').attr("src", "{:captcha_src()}?" + random);
    }
</script>
</body>
</html>
